package com.david.func_test;

import android.app.Application;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Debug;
import android.util.Log;
import android.widget.Toast;

public class App extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.e("BootUpReceiver", "App.onCreate()。。。。。。");
        Log.e("BootUpReceiver", "App.onCreate() isSupportStepCountSensor：。。。。。。"+ isSupportStepCountSensor(this));
        Toast.makeText(this, "App.onCreate()。。。。。。", Toast.LENGTH_LONG).show();

        ToastUtils.Companion.getInstance().init(this);
    }

    /**
     * 判断该设备是否支持计歩
     *
     * @param context
     * @return
     */
    public static boolean isSupportStepCountSensor(Context context) {
        // 获取传感器管理器的实例
        SensorManager sensorManager = (SensorManager) context
                .getSystemService(context.SENSOR_SERVICE);
        Sensor countSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
        Sensor detectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);
        return countSensor != null || detectorSensor != null;
    }

}
